package com.rbac.web.model;

import java.util.Objects;

/**
 * @author gengaoliu
 */
public class UserContext {
  private UserContext() {}

  private static final ThreadLocal<User> USER_HOLDER = new ThreadLocal<>();

  public static void remove() {
    USER_HOLDER.remove();
  }

  public static User get() {
    return USER_HOLDER.get();
  }

  public static void set(User user) {
    Objects.requireNonNull(user, "User class cannot be null");
    USER_HOLDER.set(user);
  }
}
